<?php
    echo "<p id='captcha_url' style='display: none'>{$this->captcha_url}</p>";
    // 博客标题
    echo "<div class='blogTitle'><h3>".$this->blog->title."</h3>";
   // 作者
    $auth = Zend_Auth::getInstance();
    if ($auth->hasIdentity()) {
          if($auth->getIdentity()->id == $this->blog->uid){
            echo "<div class = 'panel'>";
            echo" <span><a href='/blog/delete/id/".$this->blog->id."'>删除</a></span> | ";
            echo "<span><a href='/blog/update/id/".$this->blog->id."'>编辑</a></span>";
            echo "</div>";
           }
    }
    echo "</div>";
    echo "<div class='blogBody'>";
    // 分类
    if ($this->blog->name){
        echo "<span class='info'><a href='/blog/index/category_id/".$this->blog->cid."'>".$this->blog->name."</a></span> ";
    }
    else {
        echo "<span class='info'>无分类</span>";
        
    }
    echo "<span class = 'info'>".date("Y年m月d日 h点m分",$this->blog->createtime)."</span> ";
    echo "<span class = 'info'><a href='/user/account/id/".$this->blog->uid."'>".$this->blog->username."</a></span> ";
    
    echo "<hr />";
    // 博客内容
    echo $this->blog->body;
    echo "</div>";
    
    // tags
    if ($this->tags){
        echo "<br />Tags: ";
        foreach($this->tags as $tag){
            echo "<span><a href = '/blog/index/tag_name/".$tag->tag."'>".$tag->tag."</a></span>  ";
        }
    }

    if ($this->comments){
        // 评论列表
        foreach ($this->comments as $comment){
            echo "<div class='adminContent'>";
            echo "<h4>".$comment->name."说：</h4>";
            echo $comment->comment;
            echo "</div>";
        }
    }
?>
<div class="adminContent">
    <script type="text/javascript" src="/js/ckeditor/ckeditor.js"></script>
    <script src="/js/jquery.js"></script>

    <?php echo $this->nologincomment; ?>
    <script type="text/javascript">
        function showcaptcha(obj) {
            var url = $("#captcha_url").html();
            if($("#captcha").attr('id')) {
                $.ajax({ url: "/blog/captcha", success: function(data){
                    $("#captcha").attr('src',data);
                }});
                return false;
            }
            $(obj).after("<img id='captcha' src=\""+url+"\">");
            $("#captcha").click(function(){
                //取Ajax返回结果
                //为了简单，这里简单地从文件中读取内容作为返回数据
                $.ajax({ url: "/blog/captcha", success: function(data){
                    $("#captcha").attr('src',data);
                }});
            });
        }
        
        CKEDITOR.replace( 'comment',
            {
                toolbar : 'Basic',
                height:100
            });
    </script>
</div>

